#use strict;
my $file1;
my $file2;
my $file3;
my $file4;
my $line;
my %hi;
my @line;
$dir = "/data1/raw/ngs/illumina-ga-1/bioinf_int/MayoGAP/mayogap_emerge/clean";
$file1 = $ARGV[0];
$file2 = $ARGV[1];
$file3 = $ARGV[2];
chomp($file1);
chomp($file2);
chomp($file3);
#$file2 = "affyprobeset_taqman_normalized.txt";
#open(BUFF1,$file1);
open BUFF1, "< $file1" or die "Can't open $file1 : $!";

#open(BUFF2,$file2);
open BUFF2, "< $file2" or die "Can't open $file2 : $!";
open(WRBUFF1,">$file3");
#open(WRBUFF1,">affyprobeset_taqman_normalized_common_probes.txt");
while($line = <BUFF1>)
{
	chomp $line;
	$line =~ s/"//g;
	$line =~ s/\r//g;
	$line =~ s/\n//g;
	$line =~ s/\t//g;
	#print "$line\n";
	$hi{$line} = 1;	
}
$line = <BUFF2>;
 print WRBUFF1 $line;

while($line = <BUFF2>)
{
        chomp $line;
        $line =~ s/"//g;
	#print "$line\n";
	$line =~ s/\s+/\t/g;
        @line = split("\t",$line);
#        print "$line[2]\n";
	$line[0] =~ s/"//g;
        $line[0] =~ s/\r//g;
        $line[0] =~ s/\n//g;
        $line[0] =~ s/\t//g;
	chomp $line[0];
        if($hi{$line[0]} ==1)
	{
		#print "succ\n";
		print WRBUFF1 $line."\n";
		#print "\n";
	}

}
